﻿/*===================================================
* 类名称: PathHelper
* 类描述:
* 创建人: oream
* 创建时间: 2017/12/25 3:05:45
* 修改人: 
* 修改时间:
* 版本： @version 1.0
=====================================================*/


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Hotfix
{
    public static class PathHelper
    {
        /// <summary>
        /// 返回AB包物体名字
        /// </summary>
        /// <param name="ConfigABPath"></param>
        /// <returns></returns>
        public static string[] GetABObjcetName(string ConfigABPath)
        {
            string[] abNameAndPrefadName = ConfigABPath.Split('/');
            string[] abAndPrefad = new string[2];
            if (abNameAndPrefadName.Length > 3)
            {
                Debug.LogWarning("InstanceManage::PathToABname() >> 路径名不符合转换");
                return null;
            }
            if (abNameAndPrefadName.Length > 2)
            {
                abAndPrefad[0] = abNameAndPrefadName[0] + "/" + abNameAndPrefadName[1] + ".assetbundle";
                abAndPrefad[1] = abNameAndPrefadName[2];
            }
            else if (abNameAndPrefadName.Length == 2)
            {
                abAndPrefad = abNameAndPrefadName;
                abAndPrefad[0] = abAndPrefad[0] + ".assetbundle";
            }
            return abAndPrefad;
        }
        /// <summary>
        /// 返回AB包名
        /// </summary>
        /// <param name="ConfigABPath"></param>
        /// <returns></returns>
        public static string GetABName(string ConfigABPath)
        {
            string[] abNameAndPrefadName = ConfigABPath.Split('/');
            string abAndPrefad = null;
            if (abNameAndPrefadName.Length > 3)
            {
                Debug.LogWarning("InstanceManage::PathToABname() >> 路径名不符合转换");
                return null;
            }
            if (abNameAndPrefadName.Length > 2)
            {
                abAndPrefad = abNameAndPrefadName[0] + "/" + abNameAndPrefadName[1] + ".assetbundle";
                return abAndPrefad;
            }
            else if (abNameAndPrefadName.Length == 2)
            {
                abAndPrefad = abNameAndPrefadName[0] + ".assetbundle";
                return abAndPrefad;
            }
            return ConfigABPath;
        }

    }
}
